import React, {Component} from 'react'
import { HashRouter as Router, Route, Switch } from 'react-router-dom'


// bundle模型用来异步加载组件
import Bundle from './bundle.js';

import ViewLoading from 'src/views/loading'
import ViewIntroContainer from 'bundle-loader?lazy!../views/intro/';
import ViewCouponContainer from 'bundle-loader?lazy!../views/coupon/';


const ViewIntro = (props) => (
    <Bundle load={ViewIntroContainer}>
        {(ViewIntro) => <ViewIntro {...props} />}
    </Bundle>
)
const ViewCoupon = (props) => (
    <Bundle load={ViewCouponContainer}>
        {(ViewCoupon) => <ViewCoupon  {...props} />}
    </Bundle>
)

const router = () => {
	return (
		<Router>
            <Switch>
                <Route exact path="/"  component={ ViewLoading } />
                <Route exact path="/intro/:mobile" component={ ViewIntro }/>
                <Route exact path="/coupon/:mobile/:coupon" component={ ViewCoupon }/>
            </Switch>
		</Router>
	)
}

export default router